package edu.trinity.cs.cjenkin1.webcrawler;

import org.htmlparser.Node;
import org.htmlparser.NodeFilter;

public abstract class CombNodeFilter implements NodeFilter {

	public abstract boolean accept(Node node);
	
	public CombNodeFilter not() {
		return new CombNodeFilter() {

			@Override
			public boolean accept(Node node) {
				return !this.accept(node);
			}
			
		};
	}
	
	public CombNodeFilter and(final CombNodeFilter filter) {
		return new CombNodeFilter() {

			@Override
			public boolean accept(Node node) {
				return this.accept(node) && filter.accept(node);
			}
			
		};
	}
	
	public CombNodeFilter or(final CombNodeFilter filter) {
		return new CombNodeFilter() {

			@Override
			public boolean accept(Node node) {
				return this.accept(node) || filter.accept(node);
			}
		};
	}

}
